<template>
  <div class="SignUp">
    <van-nav-bar safe-area-inset-top placeholder :title="$t('Fpassword')" left-arrow fixed @click-left="onClickLeft" />

    <van-form name="forget" @submit="forgetPwd">
      <div class="registered_box">
        <div class="registered_li">
          <div class="registered_li_tit required">{{$t('LoginAccount')}}</div>
          <div class="registered_li_ipt">
            <van-field clearable name="loginname" v-model="loginname" type="text" />
          </div>
        </div>
      </div>
      <div class="btnBox">
        <van-button color="linear-gradient(#F9C25F, #F5861A)" :disabled="loginname==''" round block native-type="submit">{{$t('Next')}}</van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
export default {
  data(){
    return {
      loginname:''
    }
  },
  methods: {
    onClickLeft(){
      this.$router.push({path:'/login'});
    },
    async forgetPwd(){
      this.comm.loadingShow();
      let data = await this.API.forget(localStorage.getItem('domain'),{
        'loginName':this.loginname
      });
      //0 用户不存在,1 系统错误,2 用户邮箱为空,3 邮件发送失败
      if(data.exception==0){
        this.comm.tipsShow('UserNotExist');
      }else if(data.exception==1){
        this.comm.tipsShow('SystemException');
      }else if(data.exception==2){
        this.comm.tipsShow('EmailEmpty');
      }else if(data.exception==3){
        this.comm.tipsShow('EmailSendFaild');
      }else{
        this.$router.push({path:'/resetpwd',query:{'userId':data.result}});
      }
    }
  }
}
</script>

<style lang="less">
.SignUp{
  .registered_box{
    width: 100%;
    background: #ffffff;
  }
  .registered_li{
    width: 100%;
    border-bottom: 1px solid #efefef;
  }
  .registered_li_tit{
    padding: 12px 0 0 15px;
    width: 100%;
    color: #929292;
    text-align: left;
    box-sizing: border-box;
  }
  .siteInfo{
    width: 100%;
    background: #ffffff;
    border-bottom: 1px solid #efefef;
  }
  .siteInfo_t{
    width:100%;
    height: 35px;
    padding: 8px;
    box-sizing: border-box;
  }
  .addSiteType_box{
    width: 100%;
    height: 45px;
    text-align: left;
    padding-left: 10px;
    border-bottom: 1px solid #efefef;
    box-sizing: border-box;
  }
  .addSiteType_box_l{
    float: left;
    width: 127px;
    height: 45px;
    line-height: 45px;
    font-size: 14px;
  }
  .addSiteType_box_r{
    float: left;
    width: 180px;
    height: 44px;
    line-height: 44px;
  }
  .inner{
    width: 90px;
    float: left;
    height: 44px;
    line-height: 44px;
  }
  .addSite_Agreement{
    text-decoration: underline;
    padding: 10px;
    display: flex;
    align-items:center;
    text-align: left;
    font-size: 13px;
    color: #ED7523;
    .authorCheck{
      padding-right: 10px;
    }
  }
}
</style>
